define("zui/ajax",["zui/utils","zui/dialog"],function(require,exports,module){

		var zDialog=require("zui/dialog");
		var zUtil=require("zui/utils");
		var zAjax=function(options,callback1,callback2){

				var defaultOptions=$.extend({
					 type:"post",
					 dataType:"json",
					 contentType : "application/x-www-form-urlencoded; charset=utf-8",
					 timeout:20000,
					 beforeSend:function(xhr, settings){
					 	  	 zDialog.Loading();
					 },
					 success:function(data, status, xhr){
					 	 
					 	if(zUtil.isFunction(callback1))
						 	callback1(data);
						  zDialog.closeDialog();
					 },
					 error:function(jqXHR, textStatus, errorThrown){
					      
					        var result = {
					            exception : {
					              status : textStatus,
					              errorThrown: errorThrown,
					              jqXHR : jqXHR
					            }
					          };
					         if(zUtil.isFunction(callback2)){
	   		  						  callback2(result);
	   		  				 }
					         zDialog.closeDialog();
					 }
				},options?options:{});

				$.ajax(defaultOptions);

		};

		return zAjax;
});